import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

public class BribeList implements BribeListInterface {
	private List <Briber> allBribes;
	private String className;
	
	public BribeList(String inClassName) {
		allBribes = new ArrayList<Briber>();
		className = inClassName;
	}
	
	public void addBriber(Briber who) {
		int position = allBribes.indexOf(who);
		if(position >= 0) {
			Briber realBriberFromList = allBribes.get(position);
			int amountFromSampleBriber = who.getBribe();
			realBriberFromList.addToBribe(amountFromSampleBriber);
			return;
		}

		allBribes.add(who);
	}
	
	public String getClassName() {
		return className;
	}
	
	public Briber getBiggestBriber() {
		return Collections.max(allBribes);
	}
	
	public void removeBriber(Briber byeBye) {
		allBribes.remove(byeBye);
	}
	
	public Iterator<Briber> iterator() {
		Collections.sort(allBribes);
		return allBribes.iterator();
	}
}
